package com.dmzc.stack;

import java.util.Stack;

/**
 * 6.在一串字符流中实现空格键的功能
 */
public class BackspaceStringCompare {
    public static void main(String[] args) {
        Stack stack = new Stack();
        String nStr = "a#b#b";
        char nChar;
        for (int i = 0; i < nStr.length(); i++) {
            nChar = nStr.charAt(i);
            if (nChar == '#') {
                stack.pop();

            } else {
                stack.push(nChar);
            }
        }
        Object[] objects = stack.toArray();
        for (Object object : objects) {
            System.out.println(object);
        }

    }
}
